﻿using System;
using RabbitMQ.Client;
using Service;

namespace Producer
{
    class Program
    {
        static void Main(string[] args)
        {
            var exchangeName = "TestExchange";
            var queueName = "TRabbitMQ";
            var routingKey = "Test";

            MessageQueue messageQueue = new MessageQueue("106.55.163.36", 5672, "admin", "qq1226550632");
            //messageQueue.CreateQueue(queueName, autoDelete:false);
            //messageQueue.CreateExchange(exchangeName, ExchangeTypes.direct, autoDelete: false);
            //messageQueue.BindQueue(queueName,exchangeName, routingKey);

            

            for (string msg = ""; msg != "send";)
            {
                if (!string.IsNullOrEmpty(msg))
                messageQueue.SendMessage(routingKey,exchangeName,msg);
                msg = Console.ReadLine();
            }

            messageQueue.Execute();
            Console.WriteLine($"已发送");
            Main(args);
        }
    }
}
